
// 修改队伍等级要求 {"序列":["0","199"]}



// @ts-ignore
export async function execute(client_id,message_json) {
    let index = message_json["序列"];
    if (index === undefined) {
        ClientUtils.send_basic_prompt(client_id, "请正确选择队员");
        return;
    }
    let min_level = index[0];
    let max_level = index[1];

    if (min_level <= 0 || max_level > 999) {
        ClientUtils.send_basic_prompt(client_id, "最低等级限制在1-999之间");
        return;
    }
    if (max_level < 10 || max_level > 999) {
        ClientUtils.send_basic_prompt(client_id, "最高等级限制在10-999之间");
        return;
    }

    let login_characters = G.Characters.get_current_login_characters(client_id);
    if (!login_characters["队长"]) {
        ClientUtils.send_basic_prompt(client_id, "你不是队长没有权限操作");
        return;
    }

    let team_data = G.TeamUtils.get_team_data(login_characters["队伍"]);
    if (team_data === undefined) {
        ClientUtils.send_basic_prompt(client_id, "队伍已不存在");
        return;
    }
    team_data["限制等级"] = [min_level, max_level];
    ClientUtils.send_basic_prompt(client_id, "修改组队等级限制成功");
    //通知队员更新内容
    let send_data = G.TeamUtils.build_send_team_data(login_characters["队伍"]);
    team_data["成员"].forEach(characters_id => {
        let character_client_id = G.Characters.get_characters_client_id(characters_id);
        if (character_client_id !== undefined) {
            ClientUtils.send_basic_prompt(client_id, `#Y队长将当前队伍等级限制修改为${min_level}-${max_level}`);
            ClientUtils.send_client_message(client_id, 4017, send_data);
        }
    });
}